package com.ticket.sass.admin.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ticket.sass.admin.business.GroupPurchaseSettingBusiness;
import com.ticket.sass.admin.dto.input.order.group.GroupPurchaseSettingAddInput;
import com.ticket.sass.admin.dto.input.order.group.GroupPurchaseSettingListInput;
import com.ticket.sass.admin.dto.input.order.group.GroupPurchaseSettingUpdInput;
import com.ticket.sass.admin.dto.output.order.group.GroupPurchaseSettingListOutput;
import com.ticket.sass.admin.model.PageModel;
import com.ticket.sass.admin.model.ResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author ywb
 * @date 2024-08-13 16:08
 */
@RestController
@AllArgsConstructor
@ApiSupport(order = 1)
@Api(tags = {"拼单订单设置-模块"})
@RequestMapping("/order-group-settings")
public class GroupPurchaseSettingController {
   final GroupPurchaseSettingBusiness business;
   
    @GetMapping
    @ApiOperation("获取设置")
    public ResultModel<PageModel<GroupPurchaseSettingListOutput>> list(
        @Valid GroupPurchaseSettingListInput input
    ) {
        return ResultModel.success(business.list(input));
    }
    
    @PostMapping
    @ApiOperation("新增设置")
    public ResultModel<String> addConfig(
        @RequestBody @Valid GroupPurchaseSettingAddInput input
    ) {
        business.add(input);
        return ResultModel.success();
    }
//
    
    @PutMapping
    @ApiOperation("修改设置")
    public ResultModel<String> updConfig(
        @RequestBody @Valid GroupPurchaseSettingUpdInput input
    ) {
        business.upd(input);
        return ResultModel.success();
    }
}
